#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<string>

using namespace std;

class Solution {
public:
    string multiply(string num1, string num2) {
        if (num1 == "0" || num2 == "0")
        {
            return "0";
        }

        string res = "0";
        int end1 = num1.size() - 1, end2 = num2.size() - 1;

        for (int i = end2; i >= 0; i--)
        {
            string cur;
            int next = 0;
            for (int j = end2; j > i; j--)
            {
                cur.push_back(0);
            }
            int val2 = num2[i] - '0';
            for (int j = end1; j >= 0; j--)
            {
                int val1 = num1[j] - '0';
                int ret = val1 * val2 + next;

                cur.push_back(ret % 10);
                next = ret / 10;
            }

            while (next != 0)
            {
                cur.push_back(next % 10);
                next /= 10;
            }
            reverse(cur.begin(), cur.end());

            for (auto& ch : cur)
            {
                ch += '0';
            }
            res = addstring(res, cur);
        }
        return res;
    }

    string addstring(string num1, string num2)
    {
        string res;
        int next = 0;
        int end1 = num1.size() - 1, end2 = num2.size() - 1;

        while (end1 >= 0 || end2 >= 0)
        {
            int val1 = end1 >= 0 ? num1[end1--] - '0' : 0;
            int val2 = end2 >= 0 ? num2[end2--] - '0' : 0;
            int ret = val1 + val2 + next;

            next = ret / 10;
            ret = ret % 10;

            res.push_back(ret + '0');
        }

        if (next != 0)
        {
            res.push_back('1');
        }

        reverse(res.begin(), res.end());

        return res;
    }
};

int main()
{
    Solution solution;

    string arr1 = "2", arr2 = "3";

    string res = solution.addstring(arr1, arr2);

    cout << res << endl;

    string r = solution.multiply(arr1, arr2);

    cout << r << endl;
    return 0;
}